package com.fast.develop.integration.context;

import com.fast.develop.core.ModuleContextFactory;
import com.fast.develop.core.context.AbstractModuleContext;
import com.fast.develop.core.context.AbstractModuleContextFactory;
import com.fast.develop.core.registry.ModuleRegistry;
import com.fast.develop.integration.HibernateModuleConfiguration;
import com.fast.develop.integration.web.MvcMappingHandlerMapping;
import com.fast.develop.meta.base.MetaConfiguration;


/**
 * @author 莫寅
 * @createTime 2022-06-08 19:08
 * @desc：
 */
public class HibernateDomainModuleContextFactory extends AbstractModuleContextFactory<HibernateModuleConfiguration> implements ModuleContextFactory<HibernateModuleConfiguration> {


    private MvcMappingHandlerMapping mvcMappingHandlerMapping;


    private ModuleRegistry moduleRegistry;

    private MetaConfiguration metaConfiguration;

    public HibernateDomainModuleContextFactory(MetaConfiguration metaConfiguration, ModuleRegistry moduleRegistry, MvcMappingHandlerMapping mvcMappingHandlerMapping) {
        super(metaConfiguration, moduleRegistry);
        this.mvcMappingHandlerMapping = mvcMappingHandlerMapping;
        this.moduleRegistry = moduleRegistry;
        this.metaConfiguration = metaConfiguration;
    }

    @Override
    protected AbstractModuleContext createModuleContext(String id, HibernateModuleConfiguration moduleConfiguration) {
        HibernateModuleContext domainModuleContext = new HibernateModuleContext(
                metaConfiguration,
                moduleRegistry,
                moduleConfiguration,
                mvcMappingHandlerMapping
        );
        return domainModuleContext;
    }

}
